<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ page import="com.byedu.entity.*" %>
<% String path=request.getContextPath(); String basePath=request.getScheme()+ "://"+request.getServerName()+ ":"+request.getServerPort()+path+ "/"; %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>贝易网校</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0, user-scaspan=no">
    <link rel="stylesheet" type="text/css" href="shop/css/iview.css">
    <script type="text/javascript" src="shop/js/vue.min.js"></script>
    <script type="text/javascript" src="shop/js/iview.min.js"></script>
    <script type="text/javascript" src="shop/js/jquery.min.js"></script>
    <script type="text/javascript">
        //点击购买按钮调用方法
        var openId = '${pOrder.openId}';
        var orderId = '${pOrder.orderId}';
        var courseId = '${pOrder.couseId}';
        var userId = '${pOrder.userId}';
        function create(){
            $(".mask").css({"display":"block"});
            //调用支付接口
            $.ajax({
                url:"../topayServlet",
                type: "post",
                data: {"openId":openId,
                    "orderId":orderId,
                    "userId":userId,
                    "courseId":courseId
                },
                dataType: "json",
                success: function(json) {
                    $(".mask").css({"display":"none"});
                    WeixinJSBridge.invoke('getBrandWCPayRequest', {
                                "appId": json.appId,
                                "timeStamp": json.timeStamp,
                                "nonceStr": json.nonceStr,
                                "package": json.packages,
                                "signType": "MD5",
                                "paySign": json.sign
                            },
                            //调起微信支付成功
                            function(res) {
                                if (res.err_msg == "get_brand_wcpay_request:ok") {
                                    //返回商品中心
                                    alert("支付成功");
                                } else {
                                    alert("支付失败");
                                }
                                window.location.href = "http://learn.by-edu.com";
                            });
                },

                error:function(){

                }
            });
            //error=0 表示增加订单后总订单数大于10
            return false;

        }
    </script>
    <style>
        *{
            margin: 0;
            padding: 0;
            font-size: 15px;
        }
        .divide{
            height: 10px;
            background-color: rgb(240,240,240);
        }
        .head{
            line-height: 40px;
            background: rgb(242,90,41);
            color: #fff;
            font-size: 20px;
            padding: 0 10px;
        }
        ul,li{
            list-style-type: none;
        }
        .box-list{
            padding: 15px 16px;
        }
        .box-list li{
            line-height: 32px;
            font-size:12px;
            color: #333;
        }
        .box-list li span.money{
            color: #d58512;
        }
        .btn-box{
            margin-top: 90px;
        }
        .btn-box a{
            display: block;
            width: 90%;
            line-height: 40px;
            margin: 30px auto;
            text-align: center;
            text-decoration: none;
            color: #fff;
            border-radius: 3px;
            background: rgb(242,90,41);
        }
        .courseName{
            padding:15px 10px;
        }
        .marginRight{
            margin-right: 10px;
        }
        .mask{
            display: none;
            position: fixed;
            width: 100%;
            height: 100%;
            background-color: rgba(0,0,0,.7);
        }
        /*遮罩层*/
        .mask .loading{
            position: absolute;
            top: 0;
            bottom: 0;
            right: 0;
            left: 0;
            margin:auto;
            z-index: 100;
            width:100%;
            height: 50px;
            line-height: 50px;
            text-align: center;
            color: #fff;
        }
        .ivu-spin-fix{
            background: none;
        }
        .rowStyle{
            width:100%;
        }

        .demo-spin-icon-load{
            animation: ani-demo-spin 1s linear infinite;

        }
        @keyframes ani-demo-spin{
            from { transform: rotate(0deg);}
            50%  { transform: rotate(180deg);}
            to   { transform: rotate(360deg);}
        }

        .demo-spin-col{
            height: 100px;
            position: absolute;
            top: 0;
            bottom: 0;
            right: 0;
            left: 0;
            margin:auto;
        }


    </style>
</head>
<body>
<div id="myapp">
    <div class="mask">
        <div class="loading">
            <Row class="rowStyle">
                <Col class="demo-spin-col" span="8">
                <Spin fix>
                    <%--<Icon type="load-b" size=45 class="demo-spin-icon-load" style="color: rgb(242,90,41);"></Icon>--%>
                    <div style="font-size: 24px;color: rgb(242,90,41);">加载中...</div>
                </Spin>
                </Col>
            </Row>
        </div>
    </div>
    <div id="pay">
        <h2 class="head">支付信息</h2>
        <p class="courseName"><span class="marginRight">课程名称:</span><span>${pOrder.couseName}</span></p>
        <div class="divide"></div>
        <ul class="box-list">
            <li><span class="marginRight">订单编号:</span><span>${pOrder.orderId}</span></li>
            <%--<li><span class="marginRight">课程介绍:</span><span>${pOrder.couseIntroduce}</span></li>--%>
            <li><span class="marginRight">订单金额:</span><span class="money">${pOrder.orderManey}</span> 元</li>
            <li><span class="marginRight">生效时间:</span><span class="starttime">${pOrder.startTime}</span></li>
            <li><span class="marginRight">失效时间:</span><span class="endtime">${pOrder.endTime}</span></li>
        </ul>
        <!--<div class="divide"></div>-->
        <!--<p class="courseName"><span>${pOrder.attendNum}人已加入学习</span></p>-->
        <!--<p style="padding: 0 10px;"><span class="marginRight">官方:</span><span>${pOrder.connectPeople}</span></p>-->
        <!--<p style="padding: 0 10px;"><span  class="marginRight">温馨提醒:</span><span>${pOrder.connectCompany}</span></p>-->
        <p class="btn-box">
            <a href="javascript:void(0);" id="btn_create" onclick="create()">微信支付</a>
        </p>
    </div>
</div>
<script>
    new Vue({
        el: '#myapp'
    })
</script>
</body>
</html>